<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width,initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no,minimal-ui" />
    <meta name="apple-mobile-web-app-capable" content="yes" />
    <meta name="renderer" content="webkit" />
    <meta name="full-screen" content="yes" />
    <meta name="x5-fullscreen" content="true" />
    <meta name="format-detection" content="telphone=no, email=no" />
    <meta name="apple-mobile-web-app-status-bar-style" content="default" />
    <title>智能应急快速搭建平台</title>
    <link rel="stylesheet" href="/form/show/index.css">
    <link rel="stylesheet" href="/form/show/FormMaking.css">
    <script type="text/javascript" src="/easyui/js/commonCss.js"></script>
    <script type="text/javascript" src="/easyui/js/commonJs.js"></script>
</head>
<body>
<div id="app">
    <fm-generate-form
            :data="jsonData"
            :remote="remoteFuncs"
            :value="editData"
            ref="generateForm"
    >
    </fm-generate-form>
    <el-button id="appleb" type="primary" @click="handleSubmit">提交</el-button>
</div>
<script src="/form/show/vue.js"></script>
<script src="/form/show/index.js"></script>
<script src="/form/show/FormMaking.umd.js"></script>
<script type="text/javascript" src="/lib/jquery/1.9.1/jquery.min.js"></script>
<script>

    (function($){
        $.getUrlParam = function(name)
        {
            var reg = new RegExp("(^|&)"+ name +"=([^&]*)(&|$)");
            var r = window.location.search.substr(1).match(reg);
            if (r!=null) return unescape(r[2]); return null;
        }
    })(jQuery);

    var cc;

    $(function() {
        //alert(window.location.href);
        //alert($.getUrlParam('taskId'));
        var taskId = $.getUrlParam('taskId')
        $.ajax({
            type: 'POST',
            contentType: "application/json;charset=UTF-8",
            url: '/process/runor/'+taskId,
            dataType: 'json',
            data:'{"dealType":"同意","dealReason":"eeeee"}',
            success: function(data){
                var obj = eval(data);
               //alert(data[0].formKey);
              // alert(data[0].taskId);
                 var formKey = data[0].formKey;
                // formKey = "2a0ce77e-d438-4624-87f8-44cf31458f1a";
                 var taskId = data[0].taskId;

                var jsonArray = [];

                    var obj = {'column': "uuid", 'type': 'eq', "value": formKey};

                    jsonArray.push(obj)


                $.ajax({
                    type: 'POST',
                    url: '/form-info/find',
                    data: {paramData: JSON.stringify(jsonArray)},
                    dataType: 'json',
                    success: function(data){
                        var jsonstr = eval(eval(data).data).content;
                     //   alert(jsonstr)

                           cc =  new Vue({
                            el: '#app',
                            data: {
                                jsonData: JSON.parse(jsonstr),
                                editData: {},
                                remoteFuncs: {

                                }
                            },
                            methods: {
                                handleSubmit () {
                                    this.$refs.generateForm.getData().then(data => {
                                        $.ajax({
                                            type: 'POST',
                                            contentType: "application/json;charset=UTF-8",
                                            url: '/runtime/tasks/do/'+taskId,
                                            dataType: 'json',
                                            data:JSON.stringify(data),
                                            //data:'{"dealType":"0","dealReason":"eeeee"}',
                                            success: function(data){
                                                history.back(-1);
                                                //layer.msg('提交成功！!',{icon:1,time:1000});
                                            },
                                            error:function(data) {
                                                console.log(data.msg);
                                            },
                                        });
                                    }).catch(e => {
                                        // data check failed
                                    })
                                }
                            }


                        })


                    }
                });


            },
            error:function(data) {
                // console.log(data.msg);
            },
        });

    });
</script>
</body>
</html>
